<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('核对记录列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>月份：</label>
                            <input type="text" name="mm" id="month" onchange="queryTableData()" placeholder="yyyy-MM-dd" th:value="${lastMonth}" autocomplete="off"/>
                        </li>
                        <li>
                            <label>状态：</label>
                            <input type="text" name="euStatus"/>
                        </li>
                        <li>
                            <label>指标：</label>
                            <input type="text" class="time-input" placeholder="请选择" name="dtCheck"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="addAllData()">
                <i class="fa fa-plus"></i> 初始数据
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('etl:record:edit')}]];
    var removeFlag = [[${@permission.hasPermi('etl:record:remove')}]];
    var prefix = ctx + "etl/check/record";
    function queryTableData() {
        $("#bootstrap-table").bootstrapTable('refresh');
    }
    function toCheck(idRecord,des) {
        $.modal.openFull("["+des+"]审核确认", prefix+"/toCheck?idRecord="+idRecord+"&month="+$("#month").val());
    }
    function lookDetail(idRecord,des) {
        $.modal.openFull("["+des+"]详情", prefix+"/toCheckDetail?idRecord="+idRecord+"&month="+$("#month").val());
    }
    function reloadFld(index, layero) {
        var iframeWin = layero.find('iframe')[0];
        iframeWin.contentWindow.submitHandler(index, layero);
        $("#bootstrap-table").bootstrapTable('refresh');
    }
    function addAllData() {
        var month = $("#month").val();
        $.ajax({
            url: prefix+'/dataInit?month='+ month,
            type: 'GET',
            dataType: 'json',
            success: function (result) {
                if(result.code=="0") {
                    $.modal.alertSuccess("数据初始化成功");
                } else {
                    $.modal.alertError(result.msg);
                }
                $("#bootstrap-table").bootstrapTable('refresh');
            }
        });
    }
    $(function() {
        $("#month").datetimepicker({
            format: "yyyy-mm",
            startView: 3,
            minView: 3,
            autoclose: true
        });
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "核对记录",
            columns: [{
                checkbox: true
            },
                {
                    field: 'idRecord',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'idConfig',
                    title: '外键',
                    visible: false
                },
                {
                    field: 'mm',
                    title: '月份'
                },
                {
                    field: 'des',
                    title: '名称'
                },
                {
                    field: 'euStatus',
                    title: '状态',
                    formatter: function(value, item, index) {
                        if(item.euStatus==1) {
                            return "已审核";
                        } else {
                            return "未审核"
                        }
                    }
                },
                {
                    field: 'dtCheck',
                    title: '审核时间'
                },
                {
                    field: 'empCheck',
                    title: '审核人'
                },
                {
                    field: 'naEmpCre',
                    title: '创建人'
                },
                {
                    field: 'dtSysCre',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.euStatus==0) {
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="toCheck('+row.idRecord+',\'' + row.des + '\')"><i class="fa fa-edit"></i>审核</a> ');
                        } else {
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="lookDetail('+row.idRecord+',\'' + row.des + '\')"><i class="fa fa-hand-pointer-o"></i>查看</a> ');
                        }
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.idRecord + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>